//答题板
// pages/sales/sales.js
var app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    syWidth: "",//系统宽度
    syHeight: "",//系统高度
    timer:0,//用时
    fsJiShu:0,//得分
    txtstr:"表现不错！",//提示字
    dacuo:"",//答错题数
    dadui:"",//答对
    lianxisai:true,//是否是练习赛
    manfen:true,//是否是满分
    jxdtBool:true,//继续答题按钮显示
    fxpyBool:true,//分享给朋友
    fxpyqBool: true,//分享给朋友圈
    manfenflag:"",//满分个数
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
 var that = this
    console.log("计时器:" + options.timer + "|得分: " + options.fsJiShu)
    var timerC = options.timer/100;
    var fsJiShuC = options.fsJiShu;
    var modeC = options.modeC;
    console.log("练习模式开启:" + modeC + "当前答对" + that.data.fsJiShuC)

    if (modeC=="true"){
      that.setData({
        jxdtBool:false,
      })
    
    }else{
    
   }
 
    //获取设备宽高
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          syWidth: res.windowWidth,
          syHeight: res.windowHeight,
          timer: timerC,
          fsJiShu: fsJiShuC
         
        })
      }
    })

  },
  //满分
  manfenOnClick:function(){
    var that=this;
    var _wxid = app.globalData.userwxid;

    console.log("满分用户WXID：" + _wxid)
    that.addmanfen(_wxid);
    that.setData({
      lianxisai:true,
      manfen:false
    })
  }
  ,
  //增加满分用户
  addmanfen: function (wxid){
    var that = this;
    wx.request({
      url: 'https://www.citytk.com/citytk/sjbs/modeht/mode.php',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data: {
        mode: "addmenfen",
        userwxid: wxid,
      },
      method: "POST",
      success: function (res) {
        console.log("满分加载：" + res.data)
        if (res.data=="1"){
          that.getmanfen();//查询满分个数
        }else{
          console.log("插入满分失败")
        }
      },
      fail: function (e) {
        console.log("满分数据连接失败:" + e.errMsg)
      }
    })
},
//查询满分用户数
getmanfen:function(){
  var that = this;
  wx.request({
    url: 'https://www.citytk.com/citytk/sjbs/modeht/mode.php',
    header: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    data: {
      mode: "getmanfencount",
    },
    method: "POST",
    success: function (res) {
      console.log("满分数：" + res.data[0].id)
      that.setData({
        manfenflag: res.data[0].id
      })
    },
    fail: function (e) {
      console.log("满分数据连接失败:" + e.errMsg)
    }
  })
},
  //继续答题
  jxdtonClick: function () {
    var that = this;
    wx.reLaunch({
      url: '../txtedit/txtedit?mode=lianxi',
    })

  },
  //分享到朋友圈
  fxpyqonClick:function(){
    wx.navigateTo({
      url: '../fenxiang/fenxiang'
    })
  },
  //返回首页
fhsyonClick:function(){
  wx.reLaunch({
    url: '../city/city'
  })

},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },
  /**
    * 用户点击右上角分享
    */
  onShareAppMessage: function () {
    console.log("来自按钮的分享！")
    return {
      title: '嘉兴民革知识竞赛',
      path: 'pages/city/city'
    }
  }
 
})